﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace ChatDLuXService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IChat_Service" in both code and config file together.
    [ServiceContract]
    public interface IChat_Service
    {
        [OperationContract]
        DataTable GetLogin(string Username, string Password);

        [OperationContract]
        void Register(string Username, string Password, string Email);

        [OperationContract]
        bool UserExists(string Username);

        [OperationContract]
        bool EmailExists(string Email);

        [OperationContract]
        bool RoomExists(string RoomName);

        [OperationContract]
        void CreateRoom(string Roomname, string RoomDescription);

        [OperationContract]
        Model.User Login(string Username, string Password);

        [OperationContract]
        DataTable GetRooms();

        [OperationContract]
        DataTable GetRoomDetails(string RoomName);
    }

    [ServiceContract(CallbackContract = typeof(IBroadcastorCallBack))]
    public interface IBroadcastorService
    {
        [OperationContract(IsOneWay = true)]
        void RegisterClient(Model.User User);

        [OperationContract(IsOneWay = true)]
        void RegisterRoom(Model.Room Room);

        [OperationContract(IsOneWay = true)]
        void NotifyServer(EventDataType eventData);
    }

    [DataContract()]
    public class EventDataType
    {
        [DataMember]
        public long ClientID { get; set; }

        [DataMember(EmitDefaultValue=false)]
        public Model.User User { get; set; }

        [DataMember]
        public Model.Room Room { get; set; }

        [DataMember]
        public string EventMessage { get; set; }
    }

    public interface IBroadcastorCallBack
    {
        [OperationContract(IsOneWay = true)]
        void BroadcastToClient(EventDataType eventData);
    }
}
